package com.foodie.service;
import com.foodie.dao.DB;
import com.foodie.entity.Meun1;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MeunService1 {
    public  void craete(Meun1 meun1 ){
        DB.executeUpdate("INSERT INTO `t_menu_1`((`original`, `name`, `technology`, `flavor`, `difficulty`, `preparationtime`,`time`,  `number`, `image`, `content`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,)",
                meun1.getOriginal(),
                meun1.getName(),
                meun1.getTechnology(),
                meun1.getFlavor(),
                meun1.getDifficulty(),
                meun1.getDifficulty(),
                meun1.getTime(),
                meun1.getName(),
                meun1.getImage(),
                meun1.getContent());
    }
    public List<Meun1> getList(){
        List<Map<String, Object>> list = DB.executeQuery("select * from t_menu_1");
        System.out.println(list);
        Meun1 meun1;
        List<Meun1> Meun1List = new ArrayList<>();
        if (list != null ){
            for (Map<String, Object> item:list){
                meun1 = new Meun1();
                meun1.setOriginal((String) item.get("original"));
                meun1.setName((String) item.get("name"));
                meun1.setTechnology((String) item.get("technology"));
                meun1.setFlavor((String) item.get("flavor"));
                meun1.setDifficulty((String) item.get("difficulty"));
                meun1.setPreparationtime((String) item.get("preparationtime"));
                meun1.setTime((String) item.get("time"));
                meun1.setNumber((Integer) item.get("number"));
                meun1.setImage((String) item.get("image"));
                meun1.setContent((String) item.get("content"));

            }
        }
        return Meun1List;
    }
}
